#include<bits/stdc++.h>
using namespace std;

#define rint register int
int n, l, r;
int tm, ans;

inline int read ()
{
	int x = 1, s = 0;
	char ch = getchar ();
	while (ch < '0' or ch > '9')
	{
		if (ch == '-')
			x = -1;
		ch = getchar ();
	}
	while (ch >= '0' and ch <= '9')
		s = s * 10 + ch - '0', ch = getchar ();
	return x * s;
}

int main ()
{
	freopen ("candy.in", "r", stdin); freopen ("candy.out", "w", stdout);
	n = read ();
	l = read (), r = read ();
	for (rint i (l); i <= min (r, l + n - 1); ++i)
	{
		ans = max (ans, i % n);	
	}
	printf ("%d\n", ans);
	return 0;
}
